package vivek.project.pocketmoney.common.controls
{
	import mx.collections.ListCollectionView;

	public class FilterableListCollectionView extends ListCollectionView
	{
		private var _filterFunctions:Array;

		public function ArrayCollectionExtended(source:Array=null)
		{
			super(source);
		}

		public function get filterFunctions():Array
		{
			return _filterFunctions;
		}

		public function set filterFunctions(filtersArray:Array):void
		{
			_filterFunctions=filtersArray;
			this.filterFunction=complexFilter;
		}

		protected function complexFilter(item:Object):Boolean
		{
			var filterFlag:Boolean=true;
			var filter:Function;
			for each (filter in filterFunctions)
			{
				filterFlag=filter(item);
				if (!filterFlag)
					break;
			}
			return filterFlag;
		}

		override function refresh():Boolean
		{
			for each (filter in filterFunctions)
			{
				this.filterFunction=filter
				super.refresh();
			}
		}
	}
}